﻿package plugin.wing.ui
{
    import com.core.*;
    import com.greensock.*;
    import com.sh.game.display.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.bagN.*;
    import plugin.taskdialog.consts.*;
    import plugin.wing.*;
    import plugin.wing.component.*;
    import plugin.wing.controller.*;
    import pluginfw.*;
    import pluginfw.nio.*;
    import uiresource.wing.*;
    import view.mornExtends.*;
    import view.uilt.*;
    import vo.*;

    public class WingUIControl extends WingUI
    {
        public var mModelControl:WingModelControl;
        private var mLuckControl:WingLuckControl;
        public var mHorseData:Object;
        private var mPowerNumber:NumberComponent;
        private var mFirstOpen:Boolean = true;
        private var _tempUseItem:int = 0;
        private var cfgWing:Array;
        private var cfgGuanzhi:Array;
        private var cfgItems:Object;
        private var cfgWingLevel:Array;
        public var tishiView:tishiUI;
        private var AddStr:String = "";
        private var oldLuck:int = 0;
        private var mcSprite:Sprite;
        private var juexing:int = 0;
        private var oldJueXing:int = 0;
        private var _mc:XMLMovieClip;
        private var isUseMoney:int = 0;
        public var isShow:Boolean = false;
        private var cfgStore:Object;
        private var SendObj:Object;
        private var timeId:uint = 0;
        private var curtime:int;
        private var timer:Timer;
        private var _timeID:uint = 0;
        private var daojishiStr:String = "";
        private var needsec:int = 0;

        public function WingUIControl()
        {
            this.cfgWing = ConfigDictionary.data.wing;
            this.cfgGuanzhi = ConfigDictionary.data.guanwei;
            this.cfgItems = ConfigDictionary.data.item;
            this.cfgWingLevel = ConfigDictionary.data.newwinglevel;
            this.cfgStore = ConfigDictionary.data.storeNew;
            this.SendObj = new Object();
            return;
        }// end function

        override protected function createChildren() : void
        {
            viewClassMap["uiresource.wing.tishiUI"] = tishiUI;
            loadUI("Wing.xml");
            this.tishiView = tishi;
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            this.mPowerNumber = new NumberComponent();
            this.mPowerNumber.x = 448;
            this.mPowerNumber.y = 140;
            this.mPowerNumber.number = 0;
            var _loc_1:* = Control.create(WingControl, this);
            ModelProxy.addObserver("wing", _loc_1);
            PluginManager.instance.sendToServer("wing", CMDWing.Init, null);
            this.tishiView.visible = false;
            con2.visible = false;
            this.listener();
            shopLabel.addEventListener(MouseEvent.CLICK, this.onLabelClicked);
            bossLabel.addEventListener(MouseEvent.CLICK, this.onLabelClicked);
            this.mcSprite = new Sprite();
            this.mcSprite.x = 60 - 132 + 350;
            this.mcSprite.y = 300 - 188 + 10;
            this.addChild(this.mcSprite);
            return;
        }// end function

        private function onLabelClicked(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            var _loc_3:int = 0;
            if (event.currentTarget == shopLabel)
            {
                PluginManager.instance.openPlugin("store", shopLabel.localToGlobal(new Point(0, 0)), 1);
            }
            else if (event.currentTarget == bossLabel)
            {
                if (ItemUilt.checkMapIsFly())
                {
                    _loc_2 = ConfigDictionary.data.sysnpc[248];
                    _loc_3 = ItemUilt.getAllCount(101);
                    if (_loc_3 > 0)
                    {
                        PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Fly, {x:_loc_2.x, y:_loc_2.y, tostageid:_loc_2.stageid});
                    }
                    else
                    {
                        ModelProxy.change("zone", "autoMove", {x:_loc_2.x, y:_loc_2.y, tostageid:_loc_2.stageid, onhorse:true});
                    }
                    ModelProxy.change("data", "taskfindpath", _loc_2.npcid);
                    this.clearSendHandler();
                    PluginManager.instance.closePlugin("wing");
                }
            }
            return;
        }// end function

        private function listener() : void
        {
            btnItemUpgrade.addEventListener(MouseEvent.CLICK, this.itemUpgradeHandler);
            btnAutoUpgrade.addEventListener(MouseEvent.CLICK, this.autoUpgradeHandler);
            btnActive.addEventListener(MouseEvent.CLICK, this.activeHandler);
            btnClose.addEventListener(MouseEvent.CLICK, this.closeWindowHandler);
            btnActive.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler);
            btnActive.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler);
            btnItemUpgrade.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler);
            btnItemUpgrade.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler);
            btnAutoUpgrade.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler);
            btnAutoUpgrade.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler);
            jxzjBtn.addEventListener(MouseEvent.CLICK, this.addJueXingHandler);
            jxzjBtn.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler);
            jxzjBtn.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler);
            txtLuck.addEventListener(MouseEvent.MOUSE_OVER, this.luckOverHandler);
            txtLuck.addEventListener(MouseEvent.MOUSE_OUT, this.luckOutHandler);
            return;
        }// end function

        public function openRefresh(param1:Object) : void
        {
            if (this.mFirstOpen)
            {
                this.mFirstOpen = false;
                if (param1 > 0)
                {
                    this._tempUseItem = int(param1);
                }
                return;
            }
            if (this.mModelControl)
            {
                this.mModelControl.reset();
            }
            if (param1 > 0)
            {
                if (this.horseData)
                {
                    PluginManager.instance.sendToServer("bag", CMDBag.UseItem, param1);
                }
                else
                {
                    this._tempUseItem = int(param1);
                }
            }
            var _loc_2:Boolean = true;
            btnAutoUpgrade.visible = true;
            btnItemUpgrade.visible = _loc_2;
            return;
        }// end function

        public function initData(param1:Object) : void
        {
            this.mHorseData = param1[0];
            var _loc_2:* = ModelProxy.getValue("data", "user");
            if (param1[0].jihuonum)
            {
                this.juexing = param1[0].jihuonum;
            }
            else
            {
                this.juexing = 0;
            }
            juexingLabel.text = "觉醒值：" + String(this.juexing) + "/" + this.cfgWing[1].needjuexing;
            imgProgress2.width = this.juexing / this.cfgWing[1].needjuexing * 200;
            this.oldJueXing = this.juexing;
            jxzjBtn.visible = true;
            if (this.juexing == 100)
            {
                jxzjBtn.visible = false;
            }
            this.showIsCanJiHuo();
            if (!this.mHorseData.level)
            {
                con1.visible = true;
                con2.visible = false;
                btnActive.visible = true;
            }
            else
            {
                con1.visible = false;
                con2.visible = true;
                btnActive.visible = false;
            }
            if (!this.mHorseData)
            {
                this.closeWindowHandler(null);
                return;
            }
            ModelProxy.change("data", "wing", this.mHorseData);
            if (!this.mHorseData.hasOwnProperty("luck"))
            {
                this.mHorseData.luck = 0;
            }
            this.oldLuck = this.mHorseData.luck;
            if (!this.mHorseData.star)
            {
                this.mHorseData.star = 0;
            }
            this.showDaoju();
            this.mModelControl = new WingModelControl(this);
            this.mLuckControl = new WingLuckControl(this);
            this.updatePropertis();
            this.updatePoint();
            if (this._tempUseItem > 0)
            {
                PluginManager.instance.sendToServer("bag", CMDBag.UseItem, this._tempUseItem);
                this._tempUseItem = 0;
            }
            return;
        }// end function

        public function updateJueXing(param1:int) : void
        {
            this.AddStr = "觉醒值+" + (param1 - this.oldJueXing).toString();
            this.showAddZhi();
            this.juexing = param1;
            juexingLabel.text = "觉醒值：" + String(param1) + "/" + this.cfgWing[1].needjuexing;
            imgProgress2.width = this.juexing / this.cfgWing[1].needjuexing * 200;
            jxzjBtn.visible = true;
            if (this.juexing == 100)
            {
                jxzjBtn.visible = false;
            }
            this.showIsCanJiHuo();
            this.oldJueXing = param1;
            return;
        }// end function

        private function showIsCanJiHuo() : void
        {
            if (this.juexing >= 100)
            {
                btnActive.disabled = false;
            }
            else
            {
                btnActive.disabled = true;
            }
            return;
        }// end function

        public function addItem() : void
        {
            if (con2.visible == true)
            {
                this.showDaoju();
            }
            return;
        }// end function

        private function showDaoju() : void
        {
            if (!this.mHorseData.level)
            {
                return;
            }
            var _loc_1:* = (this.cfgWingLevel[this.mHorseData.level].needitem as String).split("#");
            var _loc_2:* = ItemObject.create(this.cfgItems[_loc_1[0]]);
            var _loc_3:* = ItemUilt.getAllCount(int(_loc_1[0]));
            if (_loc_3 >= int(_loc_1[1]))
            {
                daojuLabel.text = "消耗" + _loc_2.name + ":<font color=\'#53b436\'>" + _loc_1[1] + "个</font>（拥有<font color=\'#53b436\'>" + String(_loc_3) + "个</font>）";
            }
            else
            {
                daojuLabel.text = "消耗" + _loc_2.name + ":<font color=\'#ff0000\'>" + _loc_1[1] + "个</font>（拥有<font color=\'#ff0000\'>" + String(_loc_3) + "个</font>）";
            }
            return;
        }// end function

        public function showHorse(param1:Object) : void
        {
            this.showSuccess();
            this.mHorseData = param1;
            if (this.mHorseData.level > 0)
            {
                btnActive.visible = false;
                con1.visible = false;
                con2.visible = true;
                this.mModelControl.reset();
                this.showDaoju();
            }
            this.updatePropertis();
            this.updateLuck();
            return;
        }// end function

        private function showSuccess() : void
        {
            if (this._mc == null)
            {
                XMLMcManager.instance.MainuiMc("qianghuasucces1", this.getBack);
            }
            else
            {
                this.addChild(this._mc);
                this._mc.playFromTo(-1, (this._mc.totalFrame - 1), new Handler(this.doEnd1));
            }
            return;
        }// end function

        private function getBack(param1:XMLMovieClip) : void
        {
            if (param1)
            {
                this._mc = param1;
                this._mc.mouseChildren = false;
                this._mc.mouseEnabled = false;
                this._mc.x = 280;
                this._mc.y = -60;
                this.addChild(this._mc);
                this._mc.playFromTo(-1, (this._mc.totalFrame - 1), new Handler(this.doEnd1));
            }
            return;
        }// end function

        private function doEnd1() : void
        {
            if (this._mc && this._mc.parent)
            {
                this._mc.parent.removeChild(this._mc);
            }
            return;
        }// end function

        public function update(param1:Object) : void
        {
            var _loc_2:Object = null;
            var _loc_4:String = null;
            if (param1[0])
            {
                _loc_2 = param1[0];
            }
            else
            {
                _loc_2 = param1;
            }
            var _loc_3:Boolean = false;
            if (this.mHorseData && _loc_2.level > this.mHorseData.level)
            {
                _loc_3 = true;
                this.showSuccessEffect();
            }
            for (_loc_4 in this.mHorseData)
            {
                
                if (_loc_2.hasOwnProperty(_loc_4))
                {
                    this.mHorseData[_loc_4] = _loc_2[_loc_4];
                }
            }
            if (!this.mHorseData.hasOwnProperty("luck"))
            {
                this.mHorseData.luck = 0;
            }
            if (_loc_3)
            {
                this.mModelControl.reset();
                PluginManager.instance.playSound(SoundType.BTN_XUNBAO);
            }
            if (_loc_3)
            {
                this.oldLuck = 0;
                this.updatePropertis();
                this.clearSendHandler();
                this.AddStr = "祝福值+" + (this.mHorseData.luck - this.oldLuck).toString();
                this.showAddZhi();
            }
            else
            {
                this.AddStr = "祝福值+" + (this.mHorseData.luck - this.oldLuck).toString();
                this.updateLuck();
            }
            this.showDaoju();
            this.oldLuck = this.mHorseData.luck;
            return;
        }// end function

        private function showSuccessEffect() : void
        {
            var _loc_1:* = XMLMcManager.instance.getPluginMc("wing", "guangyi");
            if (_loc_1)
            {
                this.mcSprite.addChild(_loc_1);
                _loc_1.mouseChildren = false;
                _loc_1.mouseEnabled = false;
                _loc_1.playFromTo(0, (_loc_1.totalFrame - 1), new Handler(this.playComplete, [_loc_1]));
            }
            return;
        }// end function

        private function playComplete(param1:XMLMovieClip) : void
        {
            if (param1)
            {
                if (param1.parent)
                {
                    param1.parent.removeChild(param1);
                }
                param1.stop();
            }
            return;
        }// end function

        private function updatePropertis() : void
        {
            if (!this.mHorseData.level && !this.mHorseData.star)
            {
                wugong.text = "0";
                phyDef.text = "0";
                hp.text = "0";
                mp.text = "0";
                return;
            }
            var _loc_1:* = this.cfgWingLevel[this.mHorseData.level];
            this.updatePower();
            wugong.text = _loc_1.phyatk + " - " + _loc_1.phyatkmax;
            phyDef.text = _loc_1.phydefmin + " - " + _loc_1.phydefmax;
            hp.text = String(int(_loc_1.percenthp) / 100) + "%";
            mp.text = String(int(_loc_1.percentmp) / 100) + "%";
            this.AddStr = "祝福值+" + (this.mHorseData.luck - this.oldLuck).toString();
            this.updateLuck();
            return;
        }// end function

        private function get nextStarData() : Object
        {
            var _loc_1:int = 0;
            if (this.mHorseData)
            {
                _loc_1 = this.mHorseData.level + 1;
                if (this.cfgWingLevel[_loc_1])
                {
                    return this.cfgWingLevel[_loc_1];
                }
            }
            return null;
        }// end function

        public function get horseData() : Object
        {
            return this.mHorseData;
        }// end function

        public function updatePower() : void
        {
            var _loc_1:* = this.cfgWingLevel[this.mHorseData.level];
            this.mPowerNumber.number = int(_loc_1.power);
            return;
        }// end function

        private function updateLuck() : void
        {
            this.AddStr = "祝福值+" + (this.mHorseData.luck - this.oldLuck).toString();
            this.showAddZhi();
            var _loc_1:* = this.cfgWingLevel[this.mHorseData.level];
            var _loc_2:* = Math.min(this.mHorseData.luck / _loc_1.luck, 1);
            txtLuck.text = StringUtil.substitute("祝福值 {0}", this.mHorseData.luck);
            txtLuck.x = imgProgress.x + (192 - txtLuck.width) / 2;
            this.mLuckControl.updateProgress(this.mHorseData.luck);
            this.oldLuck = this.mHorseData.luck;
            return;
        }// end function

        public function updatePoint() : void
        {
            var _loc_1:* = UserData.getBagData("zuoqi");
            return;
        }// end function

        private function showUpPropertis(param1:Boolean) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            if (param1)
            {
                upContainer.visible = true;
                _loc_2 = this.nextStarData;
                if (_loc_2)
                {
                    _loc_3 = ConfigDictionary.data.newwinglevel[(this.mHorseData.level + 1)];
                    if (!_loc_3)
                    {
                        return;
                    }
                    label1.text = _loc_3.phyatk + " - " + _loc_3.phyatkmax;
                    label4.text = _loc_3.phydefmin + " - " + _loc_3.phydefmax;
                    label6.text = String(int(_loc_3.percenthp) / 100) + "%";
                    label7.text = String(int(_loc_3.percentmp) / 100) + "%";
                }
                else
                {
                    _loc_4 = ConfigDictionary.data.newwinglevel[1];
                    label1.text = _loc_4.phyatk + " - " + _loc_4.phyatkmax;
                    label4.text = _loc_4.phydefmin + " - " + _loc_4.phydefmax;
                    label6.text = String(int(_loc_4.percenthp) / 100) + "%";
                    label7.text = String(int(_loc_4.percentmp) / 100) + "%";
                }
            }
            else
            {
                upContainer.visible = false;
            }
            return;
        }// end function

        private function itemUpgradeHandler(event:MouseEvent) : void
        {
            if (!this.nextStarData)
            {
                ModelProxy.change("movetips", "error", "已经升至顶级");
                return;
            }
            if (this.mHorseData.level >= 6 && this.mHorseData.star >= 10)
            {
                ModelProxy.change("movetips", "error", "需要激活才可进阶");
                return;
            }
            this.showTishiView(0);
            return;
        }// end function

        private function showTishiView(param1:int) : void
        {
            var _loc_2:* = (this.cfgWingLevel[this.mHorseData.level].needitem as String).split("#");
            var _loc_3:* = ItemUilt.getAllCount(int(_loc_2[0]));
            if (_loc_3 < _loc_2[1])
            {
                if (this.isShow == false)
                {
                    this.tishiView.visible = true;
                    if (param1 == 1)
                    {
                        this.clearSendHandler();
                    }
                }
                else
                {
                    this.tishiView.visible = false;
                    this.sendJinJie(param1);
                }
                this.tishiView.yuanbaoLabel.text = this.cfgStore[_loc_2[2]].nowprice;
                this.tishiView.nameLabel.text = this.cfgItems[_loc_2[0]].name + "*1" + "= ";
                this.tishiView.sureBtn.clickHandler = new Handler(this.onSure, [param1]);
                this.tishiView.cancleBtn.clickHandler = new Handler(this.onCancel, [param1]);
                this.tishiView.closeBtn.clickHandler = new Handler(this.onClose);
                this.tishiView.checkBox.clickHandler = new Handler(this.onCheckBox);
            }
            else
            {
                this.tishiView.visible = false;
                this.sendJinJie(param1);
            }
            return;
        }// end function

        private function onSure(param1:int) : void
        {
            this.isUseMoney = 1;
            this.tishiView.visible = false;
            this.sendJinJie(param1);
            return;
        }// end function

        private function onCancel(param1:int) : void
        {
            this.isUseMoney = 0;
            this.tishiView.visible = false;
            return;
        }// end function

        private function onClose() : void
        {
            this.tishiView.visible = false;
            return;
        }// end function

        private function onCheckBox() : void
        {
            this.isShow = this.tishiView.checkBox.selected;
            return;
        }// end function

        public function sendJinJie(param1:int) : void
        {
            var _loc_2:* = (this.cfgWingLevel[this.mHorseData.level].needitem as String).split("#");
            var _loc_3:* = ItemObject.create(this.cfgItems[_loc_2[0]]);
            var _loc_4:* = ItemUilt.getAllCount(int(_loc_2[0]));
            if (ItemUilt.getAllCount(int(_loc_2[0])) < int(_loc_2[1]) && this.isUseMoney == 0)
            {
                WarningManager.show(60);
                return;
            }
            var _loc_5:* = new Object();
            _loc_5 = {item:int(_loc_2[1]), usemoney:this.isUseMoney, type:0};
            if (param1 == 0)
            {
                PluginManager.instance.sendToServer("wing", CMDWing.Uplevel, _loc_5);
                PluginManager.instance.playSound(SoundType.BTN_ARMON2);
                ModelProxy.change("mainview", "showWingCount", null);
            }
            else if (btnAutoUpgrade.label == "停止进阶")
            {
                this.clearSendHandler();
            }
            else
            {
                this.SendObj = _loc_5;
                if (this.timeId == 0)
                {
                    this.timeId = setInterval(this.sendHandler, 200);
                }
            }
            return;
        }// end function

        private function sendHandler() : void
        {
            var _loc_1:* = (this.cfgWingLevel[this.mHorseData.level].needitem as String).split("#");
            var _loc_2:* = ItemObject.create(this.cfgItems[_loc_1[0]]);
            var _loc_3:* = ItemUilt.getAllCount(int(_loc_1[0]));
            var _loc_4:* = _loc_1[1] * this.cfgStore[_loc_1[2]].nowprice;
            var _loc_5:* = UserData.getBagData();
            var _loc_6:* = UserData.getBagData().money;
            if (this.isUseMoney == 0)
            {
                if (_loc_3 < int(_loc_1[1]))
                {
                    this.clearSendHandler();
                    WarningManager.show(60);
                }
                else
                {
                    btnAutoUpgrade.label = "停止进阶";
                    btnItemUpgrade.disabled = true;
                    PluginManager.instance.sendToServer("wing", CMDWing.Uplevel, this.SendObj);
                    PluginManager.instance.playSound(SoundType.BTN_ARMON2);
                }
            }
            else if (this.isUseMoney == 1)
            {
                if (_loc_6 < _loc_4)
                {
                    this.clearSendHandler();
                    WarningManager.show(42);
                }
                else
                {
                    btnAutoUpgrade.label = "停止进阶";
                    btnItemUpgrade.disabled = true;
                    PluginManager.instance.sendToServer("wing", CMDWing.Uplevel, this.SendObj);
                    PluginManager.instance.playSound(SoundType.BTN_ARMON2);
                }
            }
            return;
        }// end function

        private function clearSendHandler() : void
        {
            if (this.timeId > 0)
            {
                clearInterval(this.timeId);
                this.timeId = 0;
            }
            btnAutoUpgrade.label = "自动进阶";
            btnItemUpgrade.disabled = false;
            return;
        }// end function

        private function autoUpgradeHandler(event:MouseEvent) : void
        {
            if (!this.nextStarData)
            {
                ModelProxy.change("movetips", "error", "已经升至顶级");
                return;
            }
            this.showTishiView(1);
            return;
        }// end function

        private function activeHandler(event:MouseEvent) : void
        {
            var _loc_3:Output = null;
            var _loc_2:* = ModelProxy.getValue("data", "user");
            if (this.juexing < this.cfgWing[1].needjuexing)
            {
                ModelProxy.change("movetips", "error", "觉醒值不足，不能激活");
            }
            else
            {
                _loc_3 = new Output();
                PluginManager.instance.sendToBufferServer("wing", 8, _loc_3);
            }
            return;
        }// end function

        private function addJueXingHandler(event:MouseEvent) : void
        {
            var _loc_2:* = ItemUilt.getAllCount(int(this.cfgWing[1].item));
            if (_loc_2 == 0)
            {
                WarningManager.show(60);
            }
            else
            {
                PluginManager.instance.sendToServer("wing", 6, null);
            }
            return;
        }// end function

        private function rollOverHandler(event:MouseEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_2:String = "";
            switch(event.currentTarget)
            {
                case btnActive:
                {
                    this.showUpPropertis(true);
                    break;
                }
                case btnItemUpgrade:
                {
                    if (!this.mHorseData)
                    {
                        return;
                    }
                    this.showUpPropertis(true);
                    break;
                }
                case btnAutoUpgrade:
                {
                    if (!this.mHorseData)
                    {
                        return;
                    }
                    this.showUpPropertis(true);
                    _loc_2 = "<font color=\'#ef7716\'>自动培养：</font>\n<font color=\'#997f60\'>点击本按钮后将自动为您培养至下一阶段翅膀</font>\n" + "<font color=\'#ef7716\'>自动培养过程：\n" + "<font color=\'#997f60\'>1.材料不足时，自动从商城购买\n2.金币或元宝不足时，将自动停止培养\n3.培养成功后，将自动停止培养</font>";
                    break;
                }
                case jxzjBtn:
                {
                    _loc_3 = ItemUilt.getAllCount(240202027);
                    if (_loc_3 >= 1)
                    {
                        _loc_2 = "每次需要消耗" + "<font color=\'#53b436\'>" + String(_loc_3) + "/1</font>个羽毛";
                    }
                    else
                    {
                        _loc_2 = "每次需要消耗" + "<font color=\'#ff0000\'>" + String(_loc_3) + "/1</font>个羽毛";
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            if (_loc_2.length > 0)
            {
                ModelProxy.change("tips", "normal", {data:_loc_2, p:new Point()});
            }
            return;
        }// end function

        private function luckOverHandler(event:MouseEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_4:Date = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:Date = null;
            var _loc_9:int = 0;
            var _loc_10:String = null;
            var _loc_2:* = int(this.cfgWingLevel[this.mHorseData.level].ifclear);
            if (_loc_2 == 1)
            {
                _loc_3 = (ModelProxy.getValue("data", "servertime") + Number(getTimer())) / 1000;
                _loc_4 = new Date();
                _loc_5 = _loc_4.getHours();
                _loc_6 = _loc_4.getMinutes();
                _loc_7 = _loc_4.getSeconds();
                _loc_8 = new Date();
                _loc_9 = (23 - _loc_5 + 0) * 3600 + (59 - _loc_6) * 60 + (60 - _loc_7);
                this.curtime = _loc_9;
                if (this.curtime > 0)
                {
                    this._timeID = setInterval(this.timeHandler, 1000);
                    this.showText(this.curtime);
                }
            }
            else
            {
                _loc_10 = "<font color=\'#ef7716\'>当前祝福值：" + this.mHorseData.luck + "</font>\n" + "<font color=\'#4ba0ed\'>清空倒计时：无</font>\n" + "<font color=\'#ef7716\'>什么是祝福值：</font>\n" + "<font color=\'#997f60\'>翅膀升级失败后会产生祝福值，提高下次升阶成功率</font>\n" + "<font color=\'#ef7716\'>祝福值清空时间：</font>\n" + "<font color=\'#c72514\'>祝福值每天晚上0点清空</font>\n" + "<font color=\'#ef7716\'>祝福值的作用：</font>\n" + "<font color=\'#997f60\'>祝福值越高，翅膀升阶的成功率越高，当祝福值达到满值时，翅膀升阶将100%成功。</font>";
                ModelProxy.change("tips", "normal", {data:_loc_10, p:new Point()});
            }
            return;
        }// end function

        private function timeHandler() : void
        {
            var _loc_1:String = this;
            var _loc_2:* = this.curtime - 1;
            _loc_1.curtime = _loc_2;
            this.showText(this.curtime);
            if (this.curtime == 0)
            {
                if (this._timeID > 0)
                {
                    clearInterval(this._timeID);
                    this._timeID = 0;
                }
            }
            return;
        }// end function

        private function showText(param1:int) : void
        {
            if (param1 < 0)
            {
                this.daojishiStr = "00:00:00";
            }
            else
            {
                this.daojishiStr = TimeDataFormatUtil.getLeftTime2(param1);
            }
            var _loc_2:* = "<font color=\'#ef7716\'>当前祝福值：" + this.mHorseData.luck + "</font>\n" + "<font color=\'#4ba0ed\'>清空倒计时：" + this.daojishiStr + "</font>\n" + "<font color=\'#ef7716\'>什么是祝福值：</font>\n" + "<font color=\'#997f60\'>翅膀升级失败后会产生祝福值，提高下次升阶成功率</font>\n" + "<font color=\'#ef7716\'>祝福值清空时间：</font>\n" + "<font color=\'#c72514\'>祝福值每天晚上0点清空</font>\n" + "<font color=\'#ef7716\'>祝福值的作用：</font>\n" + "<font color=\'#997f60\'>祝福值越高，翅膀升阶的成功率越高，当祝福值达到满值时，翅膀升阶将100%成功。</font>";
            ModelProxy.change("tips", "normal", {data:_loc_2, p:new Point()});
            return;
        }// end function

        private function luckOutHandler(event:MouseEvent) : void
        {
            clearInterval(this._timeID);
            this._timeID = 0;
            ModelProxy.change("tips", "state", "close");
            return;
        }// end function

        private function rollOutHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            this.showUpPropertis(false);
            return;
        }// end function

        private function showAddZhi() : void
        {
            if (this.AddStr == "觉醒值+0" || this.AddStr == "祝福值+0")
            {
                return;
            }
            var _loc_1:* = new Label();
            _loc_1.text = this.AddStr;
            _loc_1.color = 15718210;
            _loc_1.bold = true;
            _loc_1.size = 14;
            _loc_1.x = 165 + 335;
            _loc_1.y = 318;
            this.addChild(_loc_1);
            TweenLite.to(_loc_1, 1.5, {y:150, alpha:0, onComplete:this.clearLabel, onCompleteParams:[_loc_1]});
            return;
        }// end function

        private function clearLabel(param1:Label) : void
        {
            if (param1)
            {
                if (param1.parent)
                {
                    param1.parent.removeChild(param1);
                }
                param1 = null;
            }
            return;
        }// end function

        private function closeWindowHandler(event:MouseEvent) : void
        {
            this.clearSendHandler();
            PluginManager.instance.closePlugin("wing");
            if (this.mModelControl.mCurModel)
            {
                this.mModelControl.mCurModel.destroy();
                this.mModelControl.mCurModel = null;
            }
            if (this.mModelControl.mNextModel)
            {
                this.mModelControl.mNextModel.destroy();
                this.mModelControl.mNextModel = null;
            }
            return;
        }// end function

    }
}
